package cn.neusoft.controller;


import cn.neusoft.exception.AppExceptionCodeMsg;
import cn.neusoft.pojo.MedicalRecord;
import cn.neusoft.pojo.Register;
import cn.neusoft.query.MedicalRecordQuery;
import cn.neusoft.service.IMedicalRecordService;
import cn.neusoft.vo.ResultBean;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hxj
 * @since 2024-12-18
 */
@RestController
@RequestMapping("/medicalrecord")
public class MedicalRecordController extends BaseController<MedicalRecord, MedicalRecordQuery>{

    @Autowired
    IMedicalRecordService medicalRecordService;

    /*
    通过挂号id查询病例
     */
    @GetMapping("/register/{rid}")
    public ResultBean getByRegId(@PathVariable("rid") Integer registerId){
        QueryWrapper<MedicalRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("register_id",registerId);

        MedicalRecord one = medicalRecordService.getOne(queryWrapper);

        return one==null?
                ResultBean.ERROR(AppExceptionCodeMsg.DATA_NOT_FOUND)
                :ResultBean.SUCCESS(one);

    }

}
